package com.gt.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gt.common.annotation.Log;
import com.gt.common.core.controller.BaseController;
import com.gt.common.core.domain.AjaxResult;
import com.gt.common.enums.BusinessType;
import com.gt.admin.domain.FlowDetail;
import com.gt.admin.service.IFlowDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 随访明细controller
 */
@Api(tags = "sc-随访明细")
@RestController
@RequestMapping("/flow-config/detail")
public class FlowDetailController extends BaseController {
    @Autowired
    private IFlowDetailService flowDetailService;

    /**
     * 查询随访明细
     */
    @ApiOperation("查询随访明细")
    @GetMapping("/list")
    public AjaxResult list(FlowDetail flowDetail){
        LambdaQueryWrapper<FlowDetail> queryWrapper = new LambdaQueryWrapper<>(flowDetail);
        List<FlowDetail> flowDetailList = flowDetailService.list(queryWrapper);
        return AjaxResult.success(flowDetailList);
    }

    /**
     * 新增随访明细
     */
    @ApiOperation("新增随访明细")
    @Log(title = "随访明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult insert(@RequestBody FlowDetail flowDetail){
        return toAjax(flowDetailService.save(flowDetail));
    }

    /**
     * 修改随访明细
     */
    @ApiOperation("修改随访明细")
    @Log(title = "随访明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult update(@RequestBody FlowDetail flowDetail){
        return toAjax(flowDetailService.updateById(flowDetail));
    }

    /**
     * 删除随访明细
     */
    @ApiOperation("删除随访明细")
    @Log(title = "随访明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable("id") Long id){
        return toAjax(flowDetailService.removeById(id));
    }
}
